package com.itheima.Demo;

import com.itheima.domain.User;
import com.itheima.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class TestDemo {

//    在spring中集成mybatis的测试

    public static void main(String[] args) {

        //读取spring的配置文件  获取对象
        ApplicationContext ac = new ClassPathXmlApplicationContext("spring.xml");

        //根据对象获取 userService 对象  由于类名称唯一 getBean不需要指定 id
        UserService userService = ac.getBean(UserService.class);
        List<User> all = userService.findAll();
        System.out.println(all);
    }
}
